import axios from "@utils/request";

//获取内容管理数据
export const getContent = (params: object) => {
  return axios.request({
    url: "/mp/articles",
    method: "get",
    params,
  });
};

//获取频道列表
export const getChannels = () => {
  return axios.request({
    url: "/channels",
    method: "get",
  });
};

//删除内容
export const deleteContent = (target: string) => {
  return axios.request({
    url: `/mp/articles/${target}`,
    method: "delete",
  });
};

//添加
export const addContent = (params: object, draft?: boolean) => {
  return axios.request({
    url: "/mp/articles",
    method: "post",
    data: params,
  });
};

//编辑回显
export const getContentById = (target: string) => {
  return axios.request({
    url: `/mp/articles/${target}`,
    method: "get",
  });
};
//编辑
export const editContent = (target: string, params: object) => {
  return axios.request({
    url: `/mp/articles/${target}`,
    method: "put",
    data: params,
  });
};
